home *** CD-ROM | disk | FTP | other *** search
/ ftp.mactech.com 2010 / ftp.mactech.com.tar / ftp.mactech.com / machack / Hacks96 / BetterADsecurity.sit / Better AD security / Source / NotifyMsg.c < prev    next >
Text File  |  1996-06-21  |  2KB  |  85 lines

  1. /*    NAME:
  2.         NotifyMsg.c
  3.  
  4.     WRITTEN BY:
  5.         Dair Grant
  6.  
  7.     DESCRIPTION:
  8.         Displays a Notification Manager dialog with a specific string.
  9.  
  10.     ___________________________________________________________________________
  11. */
  12. //=============================================================================
  13. //        Include files
  14. //-----------------------------------------------------------------------------
  15. #include <Memory.h>
  16. #include <TextUtils.h>
  17. #include <Notification.h>
  18. #include <Traps.h>
  19. #include "NotifyMsg.h"
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35. //=============================================================================
  36. //        NotificationMessage : Post a Notification Manager request.                                                                 
  37. //-----------------------------------------------------------------------------
  38. //        Note :    The NM Record is left in the System Heap.
  39. //-----------------------------------------------------------------------------
  40. pascal void NotificationMessage(short theStrings, short theStr)
  41. {    NMRec        *theNote;
  42.     short        strLen;
  43.     Str255      errorStr;
  44.  
  45.  
  46.  
  47.  
  48.     // Test for the Notification Manager. If we don't have it, just beep
  49.     if (NGetTrapAddress(_NMInstall, OSTrap) == NGetTrapAddress(_Unimplemented, ToolTrap))
  50.         SysBeep(30);
  51.  
  52.  
  53.     // Otherwise, install the request
  54.     else
  55.         {
  56.         // Allocate and initialise a new NMRec structure    
  57.         theNote = (NMRec *) NewPtrSys(sizeof(NMRec));
  58.         if (theNote)
  59.             {
  60.             // Initialise the note structure
  61.             theNote->qType        = nmType;
  62.             theNote->nmMark        = 0;
  63.             theNote->nmIcon        = 0;
  64.             theNote->nmSound    = (Handle) -1;
  65.             theNote->nmResp        = (NMProcPtr) nil;
  66.         
  67.  
  68.             // Put the text into the note and post it
  69.             GetIndString(errorStr, theStrings, theStr);
  70.             strLen            = errorStr[0] + 1;
  71.             theNote->nmStr    = (StringPtr) NewPtr(strLen);
  72.             if (theNote->nmStr != nil && errorStr[0] == 0)
  73.                 {
  74.                 DisposPtr((Ptr) theNote);
  75.                 theNote = nil;
  76.                 }
  77.             else
  78.                 {
  79.                 BlockMoveData(errorStr, theNote->nmStr, strLen);
  80.                 NMInstall(theNote);
  81.                 }
  82.             }
  83.         }
  84. }
  85.